// MESSAGE ASCTEC_RC_DATA PACKING

#define MAVLINK_MSG_ID_ASCTEC_RC_DATA 4

typedef struct __mavlink_asctec_rc_data_t
{
 uint32_t msec; ///< Timestamp
 uint16_t value[8]; ///< RC channel values,  0...4095
 uint8_t lock; ///< Lock
} mavlink_asctec_rc_data_t;

#define MAVLINK_MSG_ID_ASCTEC_RC_DATA_LEN 21
#define MAVLINK_MSG_ID_4_LEN 21

#define MAVLINK_MSG_ASCTEC_RC_DATA_FIELD_VALUE_LEN 8

#define MAVLINK_MESSAGE_INFO_ASCTEC_RC_DATA { \
	"ASCTEC_RC_DATA", \
	3, \
	{  { "msec", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_asctec_rc_data_t, msec) }, \
         { "value", NULL, MAVLINK_TYPE_UINT16_T, 8, 4, offsetof(mavlink_asctec_rc_data_t, value) }, \
         { "lock", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_asctec_rc_data_t, lock) }, \
         } \
}


/**
 * @brief Pack a asctec_rc_data message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param msec Timestamp
 * @param value RC channel values,  0...4095
 * @param lock Lock
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_rc_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint32_t msec, const uint16_t *value, uint8_t lock)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[21];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t(buf, 20, lock);
	_mav_put_uint16_t_array(buf, 4, value, 8);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21);
#else
	mavlink_asctec_rc_data_t packet;
	packet.msec = msec;
	packet.lock = lock;
	mav_array_memcpy(packet.value, value, sizeof(uint16_t)*8);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_RC_DATA;
	return mavlink_finalize_message(msg, system_id, component_id, 21, 235);
}

/**
 * @brief Pack a asctec_rc_data message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param msec Timestamp
 * @param value RC channel values,  0...4095
 * @param lock Lock
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_asctec_rc_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint32_t msec,const uint16_t *value,uint8_t lock)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[21];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t(buf, 20, lock);
	_mav_put_uint16_t_array(buf, 4, value, 8);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21);
#else
	mavlink_asctec_rc_data_t packet;
	packet.msec = msec;
	packet.lock = lock;
	mav_array_memcpy(packet.value, value, sizeof(uint16_t)*8);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21);
#endif

	msg->msgid = MAVLINK_MSG_ID_ASCTEC_RC_DATA;
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 21, 235);
}

/**
 * @brief Encode a asctec_rc_data struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param asctec_rc_data C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_asctec_rc_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_asctec_rc_data_t* asctec_rc_data)
{
	return mavlink_msg_asctec_rc_data_pack(system_id, component_id, msg, asctec_rc_data->msec, asctec_rc_data->value, asctec_rc_data->lock);
}

/**
 * @brief Send a asctec_rc_data message
 * @param chan MAVLink channel to send the message
 *
 * @param msec Timestamp
 * @param value RC channel values,  0...4095
 * @param lock Lock
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_asctec_rc_data_send(mavlink_channel_t chan, uint32_t msec, const uint16_t *value, uint8_t lock)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[21];
	_mav_put_uint32_t(buf, 0, msec);
	_mav_put_uint8_t(buf, 20, lock);
	_mav_put_uint16_t_array(buf, 4, value, 8);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_RC_DATA, buf, 21, 235);
#else
	mavlink_asctec_rc_data_t packet;
	packet.msec = msec;
	packet.lock = lock;
	mav_array_memcpy(packet.value, value, sizeof(uint16_t)*8);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ASCTEC_RC_DATA, (const char *)&packet, 21, 235);
#endif
}

#endif

// MESSAGE ASCTEC_RC_DATA UNPACKING


/**
 * @brief Get field msec from asctec_rc_data message
 *
 * @return Timestamp
 */
static inline uint32_t mavlink_msg_asctec_rc_data_get_msec(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint32_t(msg,  0);
}

/**
 * @brief Get field value from asctec_rc_data message
 *
 * @return RC channel values,  0...4095
 */
static inline uint16_t mavlink_msg_asctec_rc_data_get_value(const mavlink_message_t* msg, uint16_t *value)
{
	return _MAV_RETURN_uint16_t_array(msg, value, 8,  4);
}

/**
 * @brief Get field lock from asctec_rc_data message
 *
 * @return Lock
 */
static inline uint8_t mavlink_msg_asctec_rc_data_get_lock(const mavlink_message_t* msg)
{
	return _MAV_RETURN_uint8_t(msg,  20);
}

/**
 * @brief Decode a asctec_rc_data message into a struct
 *
 * @param msg The message to decode
 * @param asctec_rc_data C-struct to decode the message contents into
 */
static inline void mavlink_msg_asctec_rc_data_decode(const mavlink_message_t* msg, mavlink_asctec_rc_data_t* asctec_rc_data)
{
#if MAVLINK_NEED_BYTE_SWAP
	asctec_rc_data->msec = mavlink_msg_asctec_rc_data_get_msec(msg);
	mavlink_msg_asctec_rc_data_get_value(msg, asctec_rc_data->value);
	asctec_rc_data->lock = mavlink_msg_asctec_rc_data_get_lock(msg);
#else
	memcpy(asctec_rc_data, _MAV_PAYLOAD(msg), 21);
#endif
}
